
import { _decorator, Component, Node, Graphics } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = Yuan
 * DateTime = Thu Apr 14 2022 20:22:07 GMT+0800 (中国标准时间)
 * Author = xiaopang125
 * FileBasename = Yuan.ts
 * FileBasenameNoExtension = Yuan
 * URL = db://assets/Yuan.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */

@ccclass('Yuan')
export class Yuan extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;
    rotationNum=0;
    speed=Math.random()*5;
    public piNum1;
    public piNum2;
   

    start() {
        // [3]
    //    this.piNum1=0;
    //    this.piNum2=1.8;
       this.drawArc();
      
    }
    /**
     * name
     */
    public drawArc() {
        // this.node.removeAllChildren();
        this.piNum1=Math.random()*2;
        this.piNum2=this.piNum1+Math.random()+0.3;

        const ctx = this.getComponent(Graphics);
        ctx.clear();
        ctx.lineWidth = 60;
        ctx.lineCap = 1;        
        ctx.strokeColor.fromHEX('#e98772');
        ctx.arc(0, 0, 300, this.piNum1 * Math.PI,this.piNum2 * Math.PI, true);
        ctx.stroke();
        console.log(this.piNum1,this.piNum2);
        
        
    }

    update (deltaTime: number) {
        // [4]
        // this.rotationNum-=this.speed;
        // this.node.setRotation(0,0,this.rotationNum,0);
        // this.node.setRotationFromEuler(0,0,this.rotationNum);
        

    }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
